package com.copa.l1281;

/**
 * @author copa
 * @createDate 2022-08-26 10:54
 * @function 取模运算法
 */
public class Test2 {

    public int subtractProductAndSum(int n) {
        int num1 = 0;
        // 因为初始化为0 乘上的时候永远为0
        int num2 = 1;
        int temp;
        while (n > 0) {
            temp = n % 10;
            n = n / 10;
            num1 += temp;
            num2 *= temp;
        }
        return num2 - num1;
    }

    public static void main(String[] args) {
        int n = 705;
        System.out.println(new Test2().subtractProductAndSum(n));
    }
}
